package com.test.webscoket.main;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

@Component
public class RedisMessageSender {

    @Autowired
    private RedisTemplate redisTemplate;

    // 发布消息到 Redis 频道
    public void sendMessageToClient(String clientId, String message) {
        String channel = "websocket-messages:" + clientId;
        redisTemplate.convertAndSend(channel, message);
    }
}
